﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using DQYT.HTDZ.Common;
using LTP.Accounts.Bus;
using Maticsoft.Common;
using DQYT.HTDZ.BLL;
using DQYT.HTDZ.Model;
namespace DQYT.HTDZ.Web.BDDATATABLE
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					decimal TABLE_ID=(Convert.ToDecimal(Request.Params["id"]));
					ShowInfo(TABLE_ID);
				}
			}
		}
			
	private void ShowInfo(decimal TABLE_ID)
	{
        BDDATATABLEBLL bll = new BDDATATABLEBLL();
		BDDATATABLEModel model=bll.GetModel(TABLE_ID);
		this.lblTABLE_ID.Text=model.TABLE_ID.ToString();
		this.txtTABLE_CODE.Text=model.TABLE_CODE;
		this.txtTABLE_NAME.Text=model.TABLE_NAME;
		this.txtDESCTRIPTION.Text=model.DESCTRIPTION;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtTABLE_CODE.Text.Trim().Length==0)
			{
				strErr+="TABLE_CODE不能为空！\\n";	
			}
			if(this.txtTABLE_NAME.Text.Trim().Length==0)
			{
				strErr+="TABLE_NAME不能为空！\\n";	
			}
			if(this.txtDESCTRIPTION.Text.Trim().Length==0)
			{
				strErr+="DESCTRIPTION不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			decimal TABLE_ID=decimal.Parse(this.lblTABLE_ID.Text);
			string TABLE_CODE=this.txtTABLE_CODE.Text;
			string TABLE_NAME=this.txtTABLE_NAME.Text;
			string DESCTRIPTION=this.txtDESCTRIPTION.Text;


			BDDATATABLEModel model=new BDDATATABLEModel();
			model.TABLE_ID=TABLE_ID;
			model.TABLE_CODE=TABLE_CODE;
			model.TABLE_NAME=TABLE_NAME;
			model.DESCTRIPTION=DESCTRIPTION;

			BDDATATABLEBLL bll=new BDDATATABLEBLL();
			bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
